package com.ktjy.gateway.feign.fallback;

import com.ktjy.base.R;
import com.ktjy.gateway.feign.FeignAuthService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * FeignAuthServiceFallback Sentinel整合OpenFeign实现服务降级（当FeignProductService服务不可用时，FeignProductServiceFallback会被调用）
 *
 * @author LILIBO
 * @since 2025-06-04
 */
@Slf4j
@Component
public class FeignAuthServiceFallback implements FeignAuthService {

    /**
     * 登录认证
     */
    @Override
    public R login(@RequestParam String username, @RequestParam String password) {
        log.info("[服务降级] {}", username);
        return R.failure(2, "Fallback");
    }

    /**
     * 令牌验证
     */
    @Override
    public R verify(@RequestBody String token) {
        log.info("[服务降级] {}", token);
        return R.failure(2, "Fallback");
    }

    /**
     * 退出登录
     */
    @Override
    public R logout(@RequestParam Long userId) {
        log.info("[服务降级] {}", "logout");
        return R.failure(2, "Fallback");
    }

}
